/*
 * BitWriter.h
 *
 *  Created on: 22/10/2011
 *      Author: agustin
 */

#ifndef BITWRITER_H_
#define BITWRITER_H_

#include <stdio.h>
#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>

using namespace std;

class BitWriter {
public:
	BitWriter(const char* dest);
	virtual ~BitWriter();

	void escribirBit(unsigned char bit);
	size_t getPosition();
	void cerrar();
	void abrir(char* dest);

private:
	unsigned char* buffer;
	__blksize_t buff_size;
	__blksize_t buff_bit;
	size_t blocks_written;
	int fd;

	bool bufferLleno();
};

#endif /* BITWRITER_H_ */
